package com.scanner;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;

public class TargetA4 extends View {
	private Paint contourPaint = new Paint();
	
	private int displayHeight;
	private int displayWidth;
	private Point middle;
	private int diameter = 400;
	private double proportion = 0.71;
	
	
	@SuppressLint("NewApi")
	public TargetA4(Context context)
	{
		super(context);
		
		contourPaint.setStrokeWidth(8);
		contourPaint.setARGB(120, 230, 230, 0);
		setWillNotDraw(false);
		
		WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
	    Display display = wm.getDefaultDisplay();
	    Point screenSize = new Point();
	    display.getSize(screenSize);
	    displayHeight = screenSize.y;
	    displayWidth = screenSize.x;
	    middle = new Point(displayWidth/2,displayHeight/2);
	}
	

	@Override
	public void onDraw(Canvas canvas)
	{
		canvas.drawLine(middle.x - diameter, (int)(middle.y - diameter*proportion),middle.x + diameter, (int)(middle.y - diameter*proportion),contourPaint);
		canvas.drawLine(middle.x + diameter, (int)(middle.y - diameter*proportion),middle.x + diameter, (int)(middle.y + diameter*proportion),contourPaint);
		canvas.drawLine(middle.x + diameter, (int)(middle.y + diameter*proportion),middle.x - diameter, (int)(middle.y + diameter*proportion),contourPaint);
		canvas.drawLine(middle.x - diameter, (int)(middle.y + diameter*proportion),middle.x - diameter, (int)(middle.y - diameter*proportion),contourPaint);			
	}

}
